package reco.db.validation;

import reco.db.Constraint;

public class SizeConstraintFactory extends SimpleConstraintFactory implements StringConstraintFactory {
    private final int min;
    private final int max;

    public SizeConstraintFactory(int constraintMin, int constraintMax) {
        super(String.class);
        this.min = constraintMin;
        this.max = constraintMax;
    }

    @Override
    public <T> Constraint<T> createConstraint() {
        @SuppressWarnings("unchecked")
        // we already now T is String
        final Constraint<T> constraint = (Constraint<T>) new SizeConstraint(this.min, this.max);

        return constraint;
    }
}